<template>
  <div>
    <mt-header title="資金流水">
      <router-link to="/my" slot="left">
        <mt-button icon="back"></mt-button>
      </router-link>
    </mt-header>

    <!-- tab-container -->
    <mt-navbar v-model="selected">
      <div style="width: 50%" @click="getCb">
        <mt-tab-item id="1" >充幣記錄</mt-tab-item>
      </div>
      <div style="width: 50%" @click="getTb">
        <mt-tab-item id="2" >提幣記錄</mt-tab-item>
      </div>
    </mt-navbar>

    <!-- tab-container -->


    <mt-tab-container v-model="selected">
      <mt-tab-container-item id="1">
        <div class="title">
          <div>類型</div>
          <div>數量</div>
          <div>時間</div>
          <div>狀態</div>
        </div>
        <div v-for="item in cbList " class="content">
          <div>{{item.currency}}</div>
          <div>{{item.amount}}</div>
          <div>{{item.apply_time}}</div>
          <div v-if="item.status==0">審核中</div>
          <div v-if="item.status==1">審核通过</div>
          <div v-if="item.status==2">審核失败</div>
        </div>
      </mt-tab-container-item>
      <mt-tab-container-item id="2">
        <div class="title">
          <div>類型</div>
          <div>數量</div>
          <div>時間</div>
          <div>狀態</div>
        </div>
        <div v-for="item in tbList" class="content">
          <div>{{item.currency}}</div>
          <div>{{item.amount}}</div>
          <div>{{item.apply_time}}</div>

          <div v-if="item.status==0">審核中</div>
          <div v-if="item.status==1">審核通过</div>
          <div v-if="item.status==2">審核失败</div>
        </div>
      </mt-tab-container-item>
    </mt-tab-container>
  </div>

</template>

<script>
  import Vue from 'vue';
  import {Header} from 'mint-ui';

  Vue.component(Header.name, Header);
  import {Navbar, TabItem} from 'mint-ui';
  import {TabContainer, TabContainerItem} from 'mint-ui';
  import {tbjl} from "../../api/tbjl";
  import {cbjl} from "../../api/cbjl";
  Vue.component(TabContainer.name, TabContainer);
  Vue.component(TabContainerItem.name, TabContainerItem);
  Vue.component(Navbar.name, Navbar);
  Vue.component(TabItem.name, TabItem);


  export default {
    name: "index",
    data() {
      return {
        selected:'1',
        cbList:{} ,
        tbList:{} ,
        userInfo:{}
      }
    },
    methods:{
      getCb(){
        cbjl({
          uid:this.userInfo.uid
        }).then((data)=>{
          if (data.errorCode==0){
            this.cbList=data.data
          }
        });
      },
      getTb(){
        tbjl({
          uid:this.userInfo.uid
        }).then((data)=>{
          if (data.errorCode==0){
            this.tbList=data.data
          }
        })
      }
    },
    mounted() {
      if (!window.localStorage.getItem('userInfo')){
        this.$router.push({path: '/'})
      } else {
        this.userInfo = window.localStorage.getItem('userInfo');
        cbjl({
          uid:this.userInfo.uid
        }).then((data)=>{
          if (data.errorCode==0){
            this.tbList=data.data
          }
        });
        tbjl({
          uid:this.userInfo.uid
        }).then((data)=>{
          if (data.errorCode==0){
            this.cbList=data.data
          }
        })

      }

    }
  }
</script>

<style scoped>
  .content {
    display: flex;
    flex-direction: row;
    width: 100%;
    height: 46px;
    line-height: 46px;
    font-size: 14px;
    border-top: 1px solid #C0C4CC;
    border-bottom: 1px solid #4681f5;
  }
  .content div:nth-child(1){
    width: 18%;
    text-align: center;
  }
  .content div:nth-child(2){
    width: 18%;
    text-align: center;
  }
  .content div:nth-child(3){
    width: 42%;
    text-align: center;
  }
  .content div:nth-child(4){
    width: 12%;
    text-align: center;
  }
  .title {
    width: 100%;
    height: 40px;
    line-height: 40px;
    display: flex;
    flex-direction: row;
    font-size: 14px;
  }

  .title div:nth-child(1) {
    width: 18%;
    text-align: center;
  }

  .title div:nth-child(2) {
    width: 18%;
    text-align: center;
  }

  .title div:nth-child(3) {
    width: 42%;
    text-align: center;
  }

  .title div:nth-child(4) {
    width: 12%;
    text-align: center;
  }
</style>
